package com.xxgc.eow.service.impl;

import com.github.pagehelper.PageHelper;
import com.xxgc.eow.entity.Company;
import com.xxgc.eow.mapper.CompanyMapper;
import com.xxgc.eow.service.ICompanyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 企业表 服务实现类
 * </p>
 *
 * @author Mr.Abel
 * @since 2023-05-21
 */
@Service
public class CompanyServiceImpl extends ServiceImpl<CompanyMapper, Company> implements ICompanyService {

    @Resource
    private CompanyMapper companyMapper;

    @Override
    public int addCompany(Company company) {
        return companyMapper.insert(company);
    }

    @Override
    public List<Company> getAllCompany() {
        return companyMapper.selectAll();
    }

    @Override
    public Company getAllById(int companyId) {
        return companyMapper.selectByPrimaryKey(companyId);
    }

    @Override
    public int updatCompany(Company company) {
        return companyMapper.updateByPrimaryKey(company);
    }

    @Override
    public int delComany(Company company) {
        return companyMapper.deleteByPrimaryKey(company);
    }

    @Override
    public List<Company> getCompany(int pageNum, int pageSize ,String keyWord) {
        PageHelper.startPage(pageNum,pageSize);
        return companyMapper.selectByKeyWord(keyWord);
    }

    @Override
    public List<Company> getCompany(String keyWord) {
        return companyMapper.selectByKeyWord(keyWord);
    }


}
